using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace WebDauGia.Domain.Models.Mapping
{
    public class ChiTietDonNhapMap : EntityTypeConfiguration<ChiTietDonNhap>
    {
        public ChiTietDonNhapMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            // Table & Column Mappings
            this.ToTable("ChiTietDonNhap");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.iddonnhap).HasColumnName("iddonnhap");
            this.Property(t => t.idsanpham).HasColumnName("idsanpham");
            this.Property(t => t.soluong).HasColumnName("soluong");
            this.Property(t => t.dongia).HasColumnName("dongia");

            // Relationships
            this.HasRequired(t => t.DonNhapHang)
                .WithMany(t => t.ChiTietDonNhaps)
                .HasForeignKey(d => d.iddonnhap);
            this.HasRequired(t => t.SanPham)
                .WithMany(t => t.ChiTietDonNhaps)
                .HasForeignKey(d => d.idsanpham);
            this.HasRequired(t => t.SanPham1)
                .WithMany(t => t.ChiTietDonNhaps1)
                .HasForeignKey(d => d.idsanpham);

        }
    }
}
